﻿using ETModel;
using System.Collections.Generic;

namespace ETHotfix {

    /// <summary>
    /// 存放于Gate服务器的玩家实体,(Parent为GateClientSession,由ET框架维护,null表示客户端已经断开)
    /// 如果销毁,在Map服务器对应的MapPlayer会同步销毁
    /// </summary>
	public sealed class GatePlayer : Entity {
        /// <summary>
        /// 用户自定义对象
        /// </summary>
        public object UserObject { get; set; }
        /// <summary>
        /// 获取用户自定义对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetUserObject<T>() where T : class { return UserObject as T; }

        /// <summary>
        /// 当前玩家在Map服务器的Player实例ID
        /// </summary>
        public long MapPlayerInstanceId { get; set; }

        /// <summary>
        /// 释放
        /// </summary>
        public override void Dispose() {
            if (this.IsDisposed) {
                return;
            }
            base.Dispose();
            UserObject = null;
            MapPlayerInstanceId = 0;
        }
    }
}